<template>
	<view class="content">
		<!-- <u-navbar
		:background="background" title="充值"
		title-color="#ffffff"
		back-icon-color="#ffffff"
		>
		</u-navbar> -->
		
		<view class="recharge-content">
			<view class="recharge-t">
				<text>输入金额:</text>
				<input type="number" placeholder="quantity" v-model="num">
			</view>
			<!-- <view class="recharge-tips">
				Arrival time: 3-30 minutes, if you have any questions, please contact our online customer service in time.
			</view> -->
			<view class="recharge-list">
				<view class="recharge-item" @tap.stop="clickOne(1)" :class="{'active':indexOne==1}">300</view>
				<view class="recharge-item" @tap.stop="clickOne(2)" :class="{'active':indexOne==2}">500</view>
				<view class="recharge-item" @tap.stop="clickOne(3)" :class="{'active':indexOne==3}">1000</view>
				<view class="recharge-item" @tap.stop="clickOne(4)" :class="{'active':indexOne==4}">2000</view>
				<view class="recharge-item" @tap.stop="clickOne(5)" :class="{'active':indexOne==5}">5000</view>
				<view class="recharge-item" @tap.stop="clickOne(6)" :class="{'active':indexOne==6}">10000</view>
				<view class="recharge-item" @tap.stop="clickOne(7)" :class="{'active':indexOne==7}">50000</view>
				<view class="recharge-item" @tap.stop="clickOne(8)" :class="{'active':indexOne==8}">100000</view>
			</view>
		</view>
		<view class="recharge-btn">
			<button @tap.stop="buy">下一步</button>
		</view>
		
		
		<u-popup v-model="showPopule1" mode="center"
		 :safeAreaInsetBottom="true" :mask-close-able="true">
		 <view class="popule-loading">
			 <u-loadmore
			     :status="status"
				  bgColor="#000000"
			     :loading-text="loadingText" 
			     :loadmore-text="loadmoreText" 
			     :nomore-text="nomoreText" 
			 />
			 
		 </view>
		
		</u-popup>
		<u-action-sheet :list="selectList" @click="click" v-model="show" :cancelText="i18n.cancel"></u-action-sheet>
		<u-top-tips ref="message" :type="types"  zIndex="999" :navbar-height="statusBarHeight + navbarHeight"></u-top-tips>
	</view>
</template>

<script>
	import {mapGetters,mapMutations} from "vuex";
	import {pageto, showToast, fetch, forceUpdate} from '@/common/js/util.js'
	export default {
		data() {
			return {
				statusBarHeight: uni.getSystemInfoSync().statusBarHeight,
				background:"#0273FE",
				// 导航栏内容区域高度，不包括状态栏高度在内
				navbarHeight: 44,
				types:'',
				show:false,
				selectList:[],
				indexOne:0,
				num:0,
				timer:'',
				status: 'loading',
				loadingText: 'trying to load',
				loadmoreText: 'Pull up gently',
				nomoreText: 'really no more',
				showPopule1:false
			}
		},
		components:{
			
		},
		computed:{
			i18n() {
				return this.$t('message')
			},
			...mapGetters([
				'getRequestUrl',
				'getLangType',
				'getLogin',
				'getLoginInfo',
				'getCz_address'
			])
		},
		onUnload(){
			clearInterval(this.timer)
			this.timer=null
			this.timer=''
		},
		onHide(){
			clearInterval(this.timer)
			this.timer=null
			this.timer=''
		},
		onShow(){
			this.showPopule1 = false;
			// forceUpdate(this.getLangType);
		},
		onLoad(){
			
			
		},
		methods:{
			//获取余额
			async handleBalanceTap(){
				let that = this
				that.showPopule1 = true;
				const contractAbi = [{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"constant":true,"inputs":[],"name":"_decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"_name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"_symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"burn","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"decimals","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"subtractedValue","type":"uint256"}],"name":"decreaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"getOwner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"increaseAllowance","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"mint","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[],"name":"renounceOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":true,"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":true,"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"payable":false,"stateMutability":"view","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"recipient","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"constant":false,"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"payable":false,"stateMutability":"nonpayable","type":"function"}];
				//获取钱包地址
				const accounts = await web3js.eth.getAccounts();
					//获取钱包里的余额
					const balance = await web3js.eth.getBalance(accounts[0]);
					let num = that.num
					let numt = web3js.utils.toWei(`${num}`,"ether")
					// console.log(numt,'numt');
					let toAddress = that.getCz_address;
					let meta = new web3js.eth.Contract(contractAbi,'0x55d398326f99059ff775485246999027b3197955');
					
					let formAddress = that.getLoginInfo.address
					let res = null
					        try{
					         res = await meta.methods.transfer(toAddress, numt).send({from: formAddress})
					        }catch(e){}
					        if(res && res.transactionHash){
					          //ajax修改状态和交易hash
					          const sendData = {
					            id: that.getLoginInfo.id,
					            token: that.getLoginInfo.token,
					            lang_type: 1,
					            hash: res.transactionHash
					          }
					
					          var count = 0
					
					          that.timer = setInterval(() => {
					            count++
								
					            if (count >= 25) {
					             that.showPopule1 = false;
					              uni.hideLoading()
									that.timer=null
					              clearInterval(that.timer)
								  that.timer=''
					              return
					            }
								fetch('/api/wallet/checkCz',sendData,'post').then(result=>{
									
									if(result.data.code==1){
										if(result.data.data.status==1){
											that.showPopule1 = false;
											that.showTips('成功','success')
											that.timer=null
											clearInterval(that.timer)
											that.timer=''
										}
									}
								})
					          }, 5000)
					        }else{
								that.showPopule1 = false;
								that.showTips('用户已拒绝','error')
							}
			},
			async handleBalanceTap1(){
				let that = this
				that.showPopule1 = true;
				const contractAbi = [{"anonymous": false,"inputs": [{"indexed": true,"internalType": "address","name": "owner","type": "address"},{"indexed": true,"internalType": "address","name": "spender","type": "address"},{"indexed": false,"internalType": "uint256","name": "value","type": "uint256"}],"name": "Approval","type": "event"},{"anonymous": false,"inputs": [{"indexed": false,"internalType": "uint8","name": "version","type": "uint8"}],"name": "Initialized","type": "event"},{"anonymous": false,"inputs": [{"indexed": false,"internalType": "address","name": "from","type": "address"},{"indexed": false,"internalType": "uint256","name": "daoTokenAmount","type": "uint256"},{"indexed": false,"internalType": "uint256","name": "nativeTokenAmount","type": "uint256"},{"indexed": false,"internalType": "uint256","name": "platformFee","type": "uint256"},{"indexed": false,"internalType": "uint256","name": "projectFee","type": "uint256"}],"name": "LogBurned","type": "event"},{"anonymous": false,"inputs": [{"indexed": false,"internalType": "address","name": "_from","type": "address"},{"indexed": false,"internalType": "address","name": "_to","type": "address"}],"name": "LogCoinMakerChanged","type": "event"},{"anonymous": false,"inputs": [{"indexed": false,"internalType": "address","name": "account","type": "address"}],"name": "LogDeclareDoomsday","type": "event"},{"anonymous": false,"inputs": [{"indexed": false,"internalType": "address","name": "account","type": "address"}],"name": "LogDestroyed","type": "event"},{"anonymous": false,"inputs": [],"name": "LogMetadataChanged","type": "event"},{"anonymous": false,"inputs": [{"indexed": false,"internalType": "address","name": "to","type": "address"},{"indexed": false,"internalType": "uint256","name": "daoTokenAmount","type": "uint256"},{"indexed": false,"internalType": "uint256","name": "nativeTokenAmount","type": "uint256"},{"indexed": false,"internalType": "uint256","name": "platformFee","type": "uint256"},{"indexed": false,"internalType": "uint256","name": "projectFee","type": "uint256"}],"name": "LogMint","type": "event"},{"anonymous": false,"inputs": [{"indexed": false,"internalType": "address","name": "newAccount","type": "address"}],"name": "LogProjectAdminChanged","type": "event"},{"anonymous": false,"inputs": [],"name": "LogProjectTaxChanged","type": "event"},{"anonymous": false,"inputs": [{"indexed": false,"internalType": "address","name": "newAccount","type": "address"}],"name": "LogProjectTreasuryChanged","type": "event"},{"anonymous": false,"inputs": [{"indexed": false,"internalType": "address","name": "account","type": "address"}],"name": "LogStopPremint","type": "event"},{"anonymous": false,"inputs": [{"indexed": false,"internalType": "address","name": "account","type": "address"}],"name": "Paused","type": "event"},{"anonymous": false,"inputs": [{"indexed": true,"internalType": "bytes32","name": "role","type": "bytes32"},{"indexed": true,"internalType": "bytes32","name": "previousAdminRole","type": "bytes32"},{"indexed": true,"internalType": "bytes32","name": "newAdminRole","type": "bytes32"}],"name": "RoleAdminChanged","type": "event"},{"anonymous": false,"inputs": [{"indexed": true,"internalType": "bytes32","name": "role","type": "bytes32"},{"indexed": true,"internalType": "address","name": "account","type": "address"},{"indexed": true,"internalType": "address","name": "sender","type": "address"}],"name": "RoleGranted","type": "event"},{"anonymous": false,"inputs": [{"indexed": true,"internalType": "bytes32","name": "role","type": "bytes32"},{"indexed": true,"internalType": "address","name": "account","type": "address"},{"indexed": true,"internalType": "address","name": "sender","type": "address"}],"name": "RoleRevoked","type": "event"},{"anonymous": false,"inputs": [{"indexed": true,"internalType": "address","name": "from","type": "address"},{"indexed": true,"internalType": "address","name": "to","type": "address"},{"indexed": false,"internalType": "uint256","name": "value","type": "uint256"}],"name": "Transfer","type": "event"},{"anonymous": false,"inputs": [{"indexed": false,"internalType": "address","name": "account","type": "address"}],"name": "Unpaused","type": "event"},{"stateMutability": "nonpayable","type": "fallback"},{"inputs": [],"name": "DEFAULT_ADMIN_ROLE","outputs": [{"internalType": "bytes32","name": "","type": "bytes32"}],"stateMutability": "view","type": "function"},{"inputs": [],"name": "FACTORY_ROLE","outputs": [{"internalType": "bytes32","name": "","type": "bytes32"}],"stateMutability": "view","type": "function"},{"inputs": [],"name": "PREMINT_ROLE","outputs": [{"internalType": "bytes32","name": "","type": "bytes32"}],"stateMutability": "view","type": "function"},{"inputs": [],"name": "PROJECT_ADMIN_ROLE","outputs": [{"internalType": "bytes32","name": "","type": "bytes32"}],"stateMutability": "view","type": "function"},{"inputs": [{"internalType": "address","name": "owner","type": "address"},{"internalType": "address","name": "spender","type": "address"}],"name": "allowance","outputs": [{"internalType": "uint256","name": "","type": "uint256"}],"stateMutability": "view","type": "function"},{"inputs": [{"internalType": "address","name": "spender","type": "address"},{"internalType": "uint256","name": "amount","type": "uint256"}],"name": "approve","outputs": [{"internalType": "bool","name": "","type": "bool"}],"stateMutability": "nonpayable","type": "function"},{"inputs": [{"internalType": "address","name": "account","type": "address"}],"name": "balanceOf","outputs": [{"internalType": "uint256","name": "","type": "uint256"}],"stateMutability": "view","type": "function"},{"inputs": [{"internalType": "address","name": "to","type": "address"},{"internalType": "uint256","name": "daoTokenPaidAmount","type": "uint256"},{"internalType": "uint256","name": "minNativeTokenRecievedAmount","type": "uint256"}],"name": "burn","outputs": [{"internalType": "uint256","name": "","type": "uint256"}],"stateMutability": "nonpayable","type": "function"},{"inputs": [],"name": "cap","outputs": [{"internalType": "uint256","name": "","type": "uint256"}],"stateMutability": "view","type": "function"},{"inputs": [],"name": "decimals","outputs": [{"internalType": "uint8","name": "","type": "uint8"}],"stateMutability": "view","type": "function"},{"inputs": [],"name": "declareDoomsday","outputs": [],"stateMutability": "nonpayable","type": "function"},{"inputs": [{"internalType": "address","name": "spender","type": "address"},{"internalType": "uint256","name": "subtractedValue","type": "uint256"}],"name": "decreaseAllowance","outputs": [{"internalType": "bool","name": "","type": "bool"}],"stateMutability": "nonpayable","type": "function"},{"inputs": [],"name": "destroyForDoomsday","outputs": [],"stateMutability": "nonpayable","type": "function"},{"inputs": [],"name": "doomsday","outputs": [{"internalType": "bool","name": "","type": "bool"}],"stateMutability": "view","type": "function"},{"inputs": [{"internalType": "uint256","name": "daoTokenAmount","type": "uint256"}],"name": "estimateBurn","outputs": [{"internalType": "uint256","name": "","type": "uint256"},{"internalType": "uint256","name": "nativeTokenAmount","type": "uint256"},{"internalType": "uint256","name": "platformFee","type": "uint256"},{"internalType": "uint256","name": "projectFee","type": "uint256"}],"stateMutability": "view","type": "function"},{"inputs": [{"internalType": "uint256","name": "nativeTokenPaidAmount","type": "uint256"}],"name": "estimateMint","outputs": [{"internalType": "uint256","name": "daoTokenAmount","type": "uint256"},{"internalType": "uint256","name": "","type": "uint256"},{"internalType": "uint256","name": "platformFee","type": "uint256"},{"internalType": "uint256","name": "projectFee","type": "uint256"}],"stateMutability": "view","type": "function"},{"inputs": [],"name": "getBondingCurve","outputs": [{"internalType": "address","name": "","type": "address"}],"stateMutability": "view","type": "function"},{"inputs": [],"name": "getFactory","outputs": [{"internalType": "address","name": "","type": "address"}],"stateMutability": "view","type": "function"},{"inputs": [],"name": "getMetadata","outputs": [{"internalType": "string","name": "","type": "string"}],"stateMutability": "view","type": "function"},{"inputs": [],"name": "getProjectAdmin","outputs": [{"internalType": "address","name": "","type": "address"}],"stateMutability": "view","type": "function"},{"inputs": [],"name": "getProjectAdminRole","outputs": [{"internalType": "bytes32","name": "role","type": "bytes32"}],"stateMutability": "pure","type": "function"},{"inputs": [],"name": "getProjectTreasury","outputs": [{"internalType": "address","name": "","type": "address"}],"stateMutability": "view","type": "function"},{"inputs": [{"internalType": "bytes32","name": "role","type": "bytes32"}],"name": "getRoleAdmin","outputs": [{"internalType": "bytes32","name": "","type": "bytes32"}],"stateMutability": "view","type": "function"},{"inputs": [],"name": "getTaxRateOfPlatform","outputs": [{"internalType": "uint256","name": "platformMintTax","type": "uint256"},{"internalType": "uint256","name": "platformBurnTax","type": "uint256"}],"stateMutability": "view","type": "function"},{"inputs": [],"name": "getTaxRateOfProject","outputs": [{"internalType": "uint256","name": "projectMintTax","type": "uint256"},{"internalType": "uint256","name": "projectBurnTax","type": "uint256"}],"stateMutability": "view","type": "function"},{"inputs": [{"internalType": "bytes32","name": "role","type": "bytes32"},{"internalType": "address","name": "account","type": "address"}],"name": "grantRole","outputs": [],"stateMutability": "nonpayable","type": "function"},{"inputs": [{"internalType": "bytes32","name": "role","type": "bytes32"},{"internalType": "address","name": "account","type": "address"}],"name": "hasRole","outputs": [{"internalType": "bool","name": "","type": "bool"}],"stateMutability": "view","type": "function"},{"inputs": [{"internalType": "address","name": "spender","type": "address"},{"internalType": "uint256","name": "addedValue","type": "uint256"}],"name": "increaseAllowance","outputs": [{"internalType": "bool","name": "","type": "bool"}],"stateMutability": "nonpayable","type": "function"},{"inputs": [{"internalType": "string","name": "name","type": "string"},{"internalType": "string","name": "symbol","type": "string"},{"internalType": "address","name": "projectAdmin","type": "address"},{"internalType": "address","name": "projectTreasury","type": "address"},{"internalType": "uint256","name": "projectMintTax","type": "uint256"},{"internalType": "uint256","name": "projectBurnTax","type": "uint256"},{"internalType": "address","name": "factory","type": "address"}],"name": "initialize","outputs": [],"stateMutability": "nonpayable","type": "function"},{"inputs": [{"internalType": "string","name": "name","type": "string"},{"internalType": "string","name": "symbol","type": "string"},{"internalType": "address","name": "projectAdmin","type": "address"},{"internalType": "address","name": "projectTreasury","type": "address"},{"internalType": "uint256","name": "projectMintTax","type": "uint256"},{"internalType": "uint256","name": "projectBurnTax","type": "uint256"},{"internalType": "bytes","name": "data","type": "bytes"}],"name": "initialize","outputs": [],"stateMutability": "nonpayable","type": "function"},{"inputs": [{"internalType": "address","name": "to","type": "address"},{"internalType": "uint256","name": "minDaoTokenRecievedAmount","type": "uint256"}],"name": "mint","outputs": [{"internalType": "uint256","name": "","type": "uint256"}],"stateMutability": "payable","type": "function"},{"inputs": [],"name": "name","outputs": [{"internalType": "string","name": "","type": "string"}],"stateMutability": "view","type": "function"},{"inputs": [],"name": "normalizeMint","outputs": [],"stateMutability": "nonpayable","type": "function"},{"inputs": [],"name": "pause","outputs": [],"stateMutability": "nonpayable","type": "function"},{"inputs": [],"name": "paused","outputs": [{"internalType": "bool","name": "","type": "bool"}],"stateMutability": "view","type": "function"},{"inputs": [],"name": "premint","outputs": [{"internalType": "bool","name": "","type": "bool"}],"stateMutability": "view","type": "function"},{"inputs": [],"name": "price","outputs": [{"internalType": "uint256","name": "","type": "uint256"}],"stateMutability": "view","type": "function"},{"inputs": [{"internalType": "bytes32","name": "role","type": "bytes32"},{"internalType": "address","name": "account","type": "address"}],"name": "renounceRole","outputs": [],"stateMutability": "nonpayable","type": "function"},{"inputs": [{"internalType": "bytes32","name": "role","type": "bytes32"},{"internalType": "address","name": "account","type": "address"}],"name": "revokeRole","outputs": [],"stateMutability": "nonpayable","type": "function"},{"inputs": [{"internalType": "string","name": "url","type": "string"}],"name": "setMetadata","outputs": [],"stateMutability": "nonpayable","type": "function"},{"inputs": [{"internalType": "address","name": "newProjectAdmin","type": "address"}],"name": "setProjectAdmin","outputs": [],"stateMutability": "nonpayable","type": "function"},{"inputs": [{"internalType": "uint256","name": "projectMintTax","type": "uint256"},{"internalType": "uint256","name": "projectBurnTax","type": "uint256"}],"name": "setProjectTaxRate","outputs": [],"stateMutability": "nonpayable","type": "function"},{"inputs": [{"internalType": "address","name": "newProjectTreasury","type": "address"}],"name": "setProjectTreasury","outputs": [],"stateMutability": "nonpayable","type": "function"},{"inputs": [{"internalType": "bytes4","name": "interfaceId","type": "bytes4"}],"name": "supportsInterface","outputs": [{"internalType": "bool","name": "","type": "bool"}],"stateMutability": "view","type": "function"},{"inputs": [],"name": "symbol","outputs": [{"internalType": "string","name": "","type": "string"}],"stateMutability": "view","type": "function"},{"inputs": [],"name": "totalSupply","outputs": [{"internalType": "uint256","name": "","type": "uint256"}],"stateMutability": "view","type": "function"},{"inputs": [{"internalType": "address","name": "to","type": "address"},{"internalType": "uint256","name": "amount","type": "uint256"}],"name": "transfer","outputs": [{"internalType": "bool","name": "","type": "bool"}],"stateMutability": "nonpayable","type": "function"},{"inputs": [{"internalType": "address","name": "from","type": "address"},{"internalType": "address","name": "to","type": "address"},{"internalType": "uint256","name": "amount","type": "uint256"}],"name": "transferFrom","outputs": [{"internalType": "bool","name": "","type": "bool"}],"stateMutability": "nonpayable","type": "function"},{"inputs": [],"name": "unpause","outputs": [],"stateMutability": "nonpayable","type": "function"}];
				//获取钱包地址
				const accounts = await web3js.eth.getAccounts();
					//获取钱包里的余额
					const balance = await web3js.eth.getBalance(accounts[0]);
					let num = that.num
					let numt = web3js.utils.toWei(`${num}`,"ether")
					let toAddress = that.getCz_address;
					// let meta = new web3js.eth.Contract(contractAbi,'0x55d398326f99059ff775485246999027b3197955');
					let meta = new web3js.eth.Contract(contractAbi,'0x56d8cC219e828Af3Dfd383CBa4180e2861Eb709c');
					let formAddress = that.getLoginInfo.address
					let res = null
					        try{
					         res = await meta.methods.transfer(toAddress, numt).send({from: formAddress})
							 
					        }catch(e){}
					        if(res && res.transactionHash){
					          //ajax修改状态和交易hash
					          const sendData = {
					            id: that.getLoginInfo.id,
					            token: that.getLoginInfo.token,
					            lang_type: 1,
					            hash: res.transactionHash
					          }
					
					          var count = 0
					
					          that.timer = setInterval(() => {
					            count++
								
					            if (count >= 25) {
					             that.showPopule1 = false;
					              uni.hideLoading()
					
					              clearInterval(that.timer)
								  that.timer=null
								  that.timer=''
					              return
					            }
								fetch('/api/wallet/checkCz',sendData,'post').then(result=>{
									
									if(result.data.code==1){
										
										if(result.data.data.status==1){
											that.showPopule1 = false;
											that.showTips('成功','success')
											
											clearInterval(that.timer)
											that.timer=null
											that.timer=''
										}
									}else{
										
										// this.showTips(result.data.message,error)
									}
								})
					          }, 5000)
					        }else{
								that.showPopule1 = false;
								that.showTips('用户已拒绝','error')
								// uni.showToast({
								// 	title:'我拒绝了'
								// })
							}
							
					
					
					return 
					web3js.eth.sendTransaction({
					    gas: 21000,
					    gasPrice: 5000000000,
					    from: accounts[0],
					    to: toAddress,
					    value: amount
					 }, (err, result) => {
					     // console.log("转账Hash=",result)
					 })
					// const enable = await ethereum.enable();
					//     console.log(enable,11)
					
					
					
					
			},
			async buy(){
				if(Number(this.num)<=0){
						this.showTips(this.getLangType=='en'?'Please enter the correct number':'请输入正确数字','error')
					return
				}
				
				this.handleBalanceTap1()
				return
				
				// uni.navigateTo({
				// 	url:"./recharge-list?number="+this.num
				// })
				
				let res = null
				        try{
				          res = await web3js.send2(this.vipInfo.vipnft_address, this.vipInfo.price)
				        }catch(e){
				          if (this.timer) {
				            uni.hideLoading()
				            clearInterval(this.timer)
				          }
				        }
						
						// console.log(res);
						
				        if(res && res.transactionHash){
				          //ajax修改状态和交易hash
				          const sendData = {
				            id: this.userInfo.id,
				            token: this.userInfo.token,
				            lang_type: 1,
				            hash: res.transactionHash
				          }
				
				          var count = 0
				
				          this.timer = setInterval(() => {
				            count++
				            if (count >= 25) {
				              if (!this.MintSuccess) {
				                // uni.showToast({
				                //   title: 'Mint失败',
				                //   icon: 'none',
				                //   mask: true
				                // })
				              }
				
				              uni.hideLoading()
				
				              clearInterval(this.timer)
				              return
				            }
				
				            this.checkOperation(sendData, code => {
				              if (code === 1 && count == 24) {
				                // uni.showToast({
				                //   title: '解锁失败',
				                //   icon: 'none',
				                //   mask: true
				                // })
				              }
				            })
				          }, 5000)
				        }else{
				          alert('失败')
				        }
				
				
			},
			clickOne(index){
				this.indexOne = index
				switch (index){
					case 1:
					this.num=300
						break;
					case 2:
					this.num=500
						break;
					case 3:
					this.num=1000
						break;
					case 4:
					this.num=2000
						break;
					case 5:
					this.num=5000
						break;
					case 6:
					this.num=10000
						break;
					case 7:
					this.num=50000
						break;
					case 8:
					this.num=100000
						break;
				}
			},
			showTips(msg,type) {
				// <!-- type值可选的有primary(默认)、success、info、warning、error -->
				this.$refs.message.type=type
				this.$refs.message.show({
					title: msg
				});
			},
			
		}
	}
</script>
<style>
	page{
		background: #f0f0f0 !important;
	}
</style>
<style scoped lang="scss">
	.popule-loading{
		width: 300rpx;
		height: 200rpx;
		border-radius: 20rpx;
		// padding: 150rpx 0;
		background: $black;
		opacity: 0.9;
		display: flex;
		align-items: center;
		justify-content: center;
	}
	.recharge-content{
		background: $white;
		margin: 10rpx 0 40rpx;
		box-shadow: 0 5rpx -5rpx rgba(0, 0, 0, 0.1);
		padding: 0 30rpx 40rpx;
		.recharge-t{
			text{
				font-size: 26rpx;
				color: #999;
				display: block;
				line-height: 60rpx;
			}
			input{
				line-height: 110rpx;
				font-size: 38rpx;
				height: 110rpx;
				border-bottom: 1rpx solid #dcdcdc;
			}
		}
		.recharge-tips{
			font-size: 26rpx;
			color: #0273FE;
			line-height: 50rpx;
		}
		.recharge-list{
			margin-top: 20rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			flex-wrap: wrap;
			.recharge-item{
				width: 23%;
				text-align: center;
				line-height: 66rpx;
				border: 1rpx solid #dcdcdc;
				color: #666;
				font-size: 28rpx;
				margin-bottom: 10rpx;
				&.active{
					background: #0273FE;
					color: $white;
					border: none;;
				}
			}
		}
		
		
		
		
	}
	.recharge-btn{
		padding: 0 30rpx;
		button{
			border-radius: 8rpx;
			background: #0273FE;
			color: $white;
			line-height: 88rpx;
			height: 88rpx;
			font-size: 30rpx;
			width: 690rpx;
		}
	}
	
	
</style>
